import http from '../../tool/http'

const state={
    tableData:[],
    Arr1:[],
    currentData:0,
//     tableData: [
//     		{
//     	id:'1',goods_units_name:'洋葱',goods_classify_name:"蔬菜",danwei:'个',stock:'100',create_by:'杨成',create_time:"2020-3-25",
//     },{
//     	id:'2',goods_units_name:'芒果',goods_classify_name:"水果",danwei:'个',stock:'200',create_by:'杨成',create_time:"2020-3-25",
//     },{
//     	id:'3',goods_units_name:'虾',goods_classify_name:"海鲜",danwei:'只',stock:'300',create_by:'杨成',create_time:"2020-3-25",
//     },{
//     	id:'4',goods_units_name:'三鲜汤',goods_classify_name:"汤",danwei:'杯',stock:'400',create_by:'杨成',create_time:"2020-3-25",
//     },{
//     	id:'5',goods_units_name:'可乐',goods_classify_name:"饮料",danwei:'瓶',stock:'500',create_by:'杨成',create_time:"2020-3-25",
//     },
//     ],
}

const actions={

    tableDataA({commit},num){
        if(num===undefined){
            num=1;
        }
        num=(num-1)*5
        return http({
            url:'/mgrsite/depotGoods/getDepotGoodsPage',
            method: 'post',
            data:{num1:num,num2:5}
        }).then(res=>{
            commit('getData',res.data.pageList)
            // console.log(res)
            let Arr=[]
            for(let i=0;i<res.data.pageList.length;i++){
                for(let key in res.data.pageList[i]){
                    if(key==='goods_classify_name'){
                        Arr.push(res.data.pageList[i][key])
                    }
                }
            }
            Arr=[...new Set(Arr)]
            // console.log(Arr)
            commit('getArr',Arr)
            // console.log(Arr)
            return 200
        })
    },
    DataCount({commit}){
        return http({
            url:'/mgrsite/depotGoods/getDepotGoodsCount',
            method: 'post',
        }).then(res=>{
            commit('getDataA',res.data.totalCount)
            // console.log(res)
            return 200
        })
    },
}
const mutations = {
    getData(state,obj){
        state.tableData = obj
    },
    getArr(state,obj){
        state.Arr1=obj
    },
    getDataA(state,obj){
        state.currentData = obj
    },
}



export default {
    state,
    actions,
    mutations
}